package com.wtc.single;

public class SingleTon01 {
    public static void main(String[] args) {
        Friend instance = Friend.getInstance();
        System.out.println(instance);
        Friend instance1 = Friend.getInstance();
        System.out.println(instance1 == instance);
    }
}
class Friend {
    private String name;
    private static Friend friend = new Friend("可凡");
    private Friend(String name) {
        this.name = name;
    }
    public static Friend getInstance() {
        return friend;
    }

    @Override
    public String toString() {
        return "Friend{" +
                "name='" + name + '\'' +
                '}';
    }
}
